//index.js
//获取应用实例
var app = getApp()
Page({
    data: {
        motto: 'Hello World',
        userInfo: {}
    },

    formSubmit:function (e) {
        console.log(e.detail.formId)
        console.log(e);
        console.log(app.globalData.openID)
        wx.request({
            url:'https://mb.800151.com/phalapi/Public/applet/?service=Demo.wxPay',
            data:{
                fid:e.detail.formId,
                oid:app.globalData.openID,
                price:12.99
            },
            success:function (e) {
                console.log(e);
                // wx.showModal({
                //     title: '提示',
                //     content: e.data.data,
                //     showCancel: false
                // });

                var pdata = e.data.data;
                console.log(pdata);
                wx.requestPayment(
                    {
                        'timeStamp': pdata.TIMESTAMP,
                        'nonceStr': pdata.NONCE_STR,
                        'package': 'prepay_id='+pdata.PREPAY_ID,
                        'signType': 'MD5',
                        'paySign': pdata.PAY_SIGN,
                        'success':function(res){},
                        'fail':function(res){},
                        'complete':function(res){}
                    })


                /**
                 * nov4rBeEtknLaR6L"…}
                 APPID
                 :
                 "wxf44ff28bbde1722c"
                 MCH_ID
                 :
                 "1481717272"
                 NONCE_STR
                 :
                 "nov4rBeEtknLaR6L"
                 PREPAY_ID
                 :
                 "wx201706112217160ef5a9f6e30770598896"
                 RESULT_CODE
                 :
                 "SUCCESS"
                 RETURN_CODE
                 :
                 "SUCCESS"
                 RETURN_MSG
                 :
                 "OK"
                 SIGN
                 :
                 "E21054157B6C93EE52274293043C7195"
                 TIMESTAMP
                 :
                 1497190636
                 TRADE_TYPE
                 :
                 "JSAPI"
                 */
            }
        });
    },

    formReset:function (e) {
        wx.redirectTo({
            url: '/pages/index/index'
        })
    }

});
